package com.gf.gateway.common;

/**
 * @author gFly
 * @date 2024/1/12 15:38
 * @Describe
 */
public enum CommonErrors implements StandardStringEnum {
    SYSTEM_ERROR("100100000001", "系统繁忙，请稍后重试"),
    ILLEGAL_PARAMS_ERROR("100100000002", "请求参数异常: %s"),
    JSON_FORMAT_ERROR("100100000003", "JSON格式转化错误: %s"),
    PARAM_NOT_VALID_EXCEPTION("100100000004", "请求参数格式错误"),
    OPERATE_TOO_FREQUENTLY("100100000005", "您操作过于频繁，请稍后再试"),
    PERMISSION_DENIED("100100000006", "没有权限，拒绝访问"),
    ENTITY_NOT_FOUND("100100000007", "对象实体不存在"),
    ENTITY_EXISTED("100100000008", "对象实体已存在"),
    NETWORK_FAILURE("100100000009", "内部网络错误"),
    PROCESS_TIMEOUT("100100000010", "内部处理超时"),
    SYSTEM_INVALID_REQUEST("100100000011", "请求无效 %s"),
    SYSTEM_CRYPTO_ERROR("100100000012", "加解密错误"),
    RPC_FAILURE("100100000013", "RPC调用错误"),
    SYSTEM_SESSION_EXPIRED("100100000014", "当前账号登录过期，请重新登录"),
    REQUEST_NO_HANDLER_FOUND("100100000016", "请求资源不存在,请确认相关资源"),
    FILE_NOT_FOUND("100100020001", "路径：[%s]对应的文件不存在"),
    IS_FILE("100100020002", "路径：[%s]对应的是文件"),
    IS_DIRECTORY("100100020003", "路径：[%s]对应的是目录"),
    IO_ERROR("100100020004", "路径：[%s]文件读写失败"),
    FILE_EXISTS("100100020006", "路径：[%s]对应的文件已经存在");

    private final String code;
    private final String description;

    private CommonErrors(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String code() {
        return this.code;
    }

    public String description(Object... objs) {
        return String.format(this.description, objs);
    }
}
